import { ref } from "vue"

interface User{
    name: string;
    password: string;
}

interface Rules{
    name: ({
        message: string;
        required: boolean;
        trigger: string;
        min?: undefined;
        max?: undefined;
    } | {
        min: number;
        max: number;
        message: string;
        trigger: string;
        required?: undefined;
    })[];
    password: ({
        required: boolean;
        message: string;
        trigger: string;
        min?: undefined;
        max?: undefined;
    } | {
        min: number;
        max: number;
        message: string;
        trigger: string;
        required?: undefined;
    })[]; 
}

export const loginUser = ref<User>({
    name: "",
    password: "",
});

// 校验规则
export const loginRules = ref<Rules>({
    name: [{ message: "用户名不能为空", required: true, trigger: 'blur' },
    { min: 2, max: 30, message: "用户名长度必须在2-30之间", trigger: 'blur' }],
    password: [{ required: true, message: "密码不能为空", trigger: 'blur' },
    { min: 6, max: 30, message: "密码长度必须在6-30之间", trigger: 'blur' }],
})
